local GameDB = import(".GameDB")

function GameDB:queryFormulaWithSubkey(subkeyId)
    --local sql = "SELECT * from formula where subkey="..subkeyId
    local res = self:getCachedValues("formula",
        function(v)
            return v.subkey == tostring(subkeyId)
        end)
    return res
end

function GameDB:queryFormulaByShowType(showType)
    --local sql = "SELECT * from formula where showtype = " .. showType
    local res = self:getCachedValues("formula",
        function(v)
            return v.showType == tostring(showType)
        end)
    return res
end

function GameDB:queryFormulaById(id)
    return self:getCachedValue("formula",id)
end

function GameDB:getManufacturings()
    --TODO 没用到
    --local sql = "SELECT * from manufacturing"
    --local res = self:query(sql)
    --return res
    return nil
end

function GameDB:getManufacturing_subkey(id)
    --local sql = "SELECT * from manufacturing_subkey where ID="..id
    local res = self:getCachedValue("manufacturing_subkey",id)
    return res
end

function GameDB:getManufacturing_subkeys(t)
    --local sql = "SELECT * from manufacturing_subkey where type="..t
    local res = self:getCachedValues("manufacturing_subkey",
        function(v)
            return v.type == tostring(t)
        end)
    return res
end

function GameDB:queryManufacturingSubkeys()
    --local sql = "SELECT * from manufacturing_subkey"
    local res = self:getCachedValues("manufacturing_subkey")
    return res
end

function GameDB:queyManufacturingLevelupBySubkey(subkey)
    --local sql = "SELECT * from manufacturing_levelup where subkey = " .. subkey
    local res = self:getCachedValues("manufacturing_levelup",
        function(v)
            return v.subkey==tostring(subkey)
        end)
    return res
end

function GameDB:getManufacturing_levelup(sid,level)
    --local sql = "SELECT * from manufacturing_levelup where subkey="..sid.." and manufacturingLv="..level
    local res = self:getCachedValue("manufacturing_levelup",
        function(v)
            return v.subkey==tostring(sid) and v.manufacturingLv == tostring(level)
        end)
    return res
end


return GameDB